package cn.com.dycc.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.UUID;

import org.apache.tomcat.util.codec.binary.Base64;
/**
 * md5加密类
 * @author linfa
 *
 */
public class Md5Util {
	public static String MD5(String src){
		try {
			MessageDigest md = MessageDigest.getInstance("Md5");
			byte[] out = md.digest(src.getBytes());
			String ret = Base64.encodeBase64String(out);
			return ret;
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}
		
		return src;
	}
	public static String createId(){
		String id = UUID.randomUUID().toString();
		return id;
	}
	public static void main(String[] args) {
		String str = "dycc123456";
		System.out.println(MD5(str));
	}
}
